#include "POSIF.h"


void POSIF0_Init(void)
{
	WR_REG(SCU_RESET->PRSET0, SCU_RESET_PRSET0_POSIF0RS_Msk, SCU_RESET_PRSET0_POSIF0RS_Pos, 1);
	WR_REG(SCU_RESET->PRCLR0, SCU_RESET_PRCLR0_POSIF0RS_Msk, SCU_RESET_PRCLR0_POSIF0RS_Pos, 1);	
	WR_REG(SCU_CLK->CLKSET, SCU_CLK_CLKSET_CCUCEN_Msk, SCU_CLK_CLKSET_CCUCEN_Pos, 1);		
	
	WR_REG(POSIF0->PCONF, POSIF_PCONF_FSEL_Msk, POSIF_PCONF_FSEL_Pos, 0);
	WR_REG(POSIF0->PCONF, POSIF_PCONF_HIDG_Msk, POSIF_PCONF_HIDG_Pos, 1);	
	WR_REG(POSIF0->PCONF, POSIF_PCONF_MCUE_Msk, POSIF_PCONF_MCUE_Pos, 1);
	WR_REG(POSIF0->PCONF, POSIF_PCONF_LPC_Msk, POSIF_PCONF_LPC_Pos, 7);
	
	WR_REG(POSIF0->MCSM, POSIF_MCSM_MCMPS_Msk, POSIF_MCSM_MCMPS_Pos, 0x333);
	WR_REG(POSIF0->MCMS, POSIF_MCMS_MNPS_Msk, POSIF_MCMS_MNPS_Pos, 1);
	WR_REG(POSIF0->MCMS, POSIF_MCMS_STMR_Msk, POSIF_MCMS_STMR_Pos, 1);
	
	WR_REG(POSIF0->PFLGE, POSIF_PFLG_CHES_Msk, POSIF_PFLG_CHES_Pos, 1);	
	WR_REG(POSIF0->PFLGE, POSIF_PFLG_WHES_Msk, POSIF_PFLG_WHES_Pos, 1);		

}



void POSIF0_Start(void)
{
	WR_REG(POSIF0->PRUNS, POSIF_PRUNS_SRB_Msk, POSIF_PRUNS_SRB_Pos, 1);
}


void Switch_on(void)
{
	WR_REG(POSIF0->MCSM, POSIF_MCSM_MCMPS_Msk, POSIF_MCSM_MCMPS_Pos, 0x333);
	WR_REG(POSIF0->MCMS, POSIF_MCMS_STMR_Msk, POSIF_MCMS_STMR_Pos, 1);
}


void Switch_off(void)
{
	WR_REG(POSIF0->MCSM, POSIF_MCSM_MCMPS_Msk, POSIF_MCSM_MCMPS_Pos, 0x000);
	WR_REG(POSIF0->MCMS, POSIF_MCMS_STMR_Msk, POSIF_MCMS_STMR_Pos, 1);
}
